<!--
*
*  INSPINIA - Responsive Admin Theme
*  version 2.7
*
-->

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title><?=$system['sys_title']?> | <?=$title;?></title>
    <?php $this->load->view('template/css');?>
    <link rel="stylesheet" href="<?=base_url("assets/css/my.css")?>">
    <link rel="stylesheet" href="<?=base_url("assets/css/plugins/iCheck/custom.css")?>">
</head>

<body class="font16">
<?php $this->load->view('template/header');?>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 style="font-size: 18px;"><?=$title;?></h5>
                    <div class="ibox-tools" >
                        <a data-toggle="modal" style="border:1px solid #b4b6b8;padding:5px;" href="#modal-form" >
                            添加管理员
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <table class="table">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>账 号</th>
                            <th>姓 名</th>
                            <th>权 限</th>
                            <th>操 作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach($admin as $v):?>
                        <tr>
                            <td><?=$v['adm_id']?></td>
                            <td><?=$v['adm_username']?></td>
                            <td><?=$v['adm_realname']?></td>
                            <td><?=$v['adm_role']==1?'超管':'普管'?></td>
                            <td>
                                <?php if($v['adm_id']!=1 || $this->session->uid==1 ){ ?>
                                <a href="javascript:;" class="btn badge badge-info attr-edit " attr-id="<?=$v['adm_id']?>">编辑</a>
                                <?php }?>
                                <?php if($v['adm_id']!=1 && $v['adm_username']!='admin'){ ?>
                                <a href="javascript:;" class="btn badge badge-danger attr-del" attr-message="<?=$v['adm_username']?>" attr-id="<?=$v['adm_id']?>" >删除</a>
                                <?php }?>
                            </td>
                        </tr>
                        <?php endforeach;?>
                        </tbody>
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12"><h3 class="m-t-none m-b">添加管理员</h3>
                            <div class="hr-line-dashed"></div>
                            <form method="post"class="form-horizontal" id="signupForm" >
                                <input type="hidden" name="adm_id" value="">
                                <div class="form-group"><label class="col-sm-2 control-label">账号</label>
                                    <div class="col-sm-9"><input type="text" id="username"  class="form-control"  ajaxurl="<?=site_url('main/urlAjax')?>"  datatype="/^[0-1a-zA-Z_@]{4,18}$/" placeholder="请填写4至18位等登录账号，不支持特殊字符" name="adm_username"></div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">姓名</label>
                                    <div class="col-sm-9"><input type="text" datatype="*" class="form-control " placeholder="请填写姓名" name="adm_realname" ></div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">权限</label>
                                    <div class="col-sm-9"><input type="text" datatype="*" class="form-control" name=""  value="普通管理员" disabled></div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-primary"  type="submit">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var SCOPE={
        'url_form':'<?=site_url('main/submit_admin')?>',
        'url_del':'<?=site_url('main/del_admin')?>',
        'url_ajax':'<?=site_url('main/get_by_admin')?>',
        'url_edit':'<?=site_url('main/edit_admin')?>'
    }
</script>
<?php $this->load->view('template/foot');?>
<?php $this->load->view('template/scrip');?>
<!-- Jquery Validate -->
<script src="<?=base_url("assets/js/Validform_v5.3.2_min.js")?>"></script>
<script src="<?=base_url("assets/js/dialog.js")?>"></script>
<script src="<?=base_url("assets/js/jquery.form.min.js")?>"></script>
<script src="<?=base_url("assets/js/plugins/iCheck/icheck.min.js")?>"></script>
    <script>
        $(document).ready(function(){
            $('#signupForm').Validform({
                tiptype:3,
                beforeSubmit:function(data){
                    accretion(data,SCOPE.url_form);
                    return false;
                }
            });
        })
        $('.attr-edit').on('click',function(){
            var id = $(this).attr('attr-id');
            var f = $('form');
            $.get(SCOPE.url_ajax,{'id':id},function(msg){
                $('#modal-form').modal('show');
                f.find('#username').val(msg.adm_username).removeAttr('ajaxurl').removeAttr('name').attr('disabled','disabled');
                f.find("input[name='adm_realname']").val(msg.adm_realname);
                f.find("input[name='adm_id']").val(msg.adm_id);
            },'json')
        })
        $('#modal-form').on('hidden.bs.modal',function(){
            history.go(0);
            $('#signupForm').resetForm();
        })
    </script>
</body>
</html>
